################################################################################
##
## Mod Title:		Another Online/Offline indicator in Top posters on index or ezPortal from Antony Bailey
## Mod Author:		AmigaLink < webmaster@amigalink.de > (Markus Schmidt) http://www.EssenMitFreude.info  
## Mod Description:	Displays the User-Online-Status in the Top-Posters-Box of the ezPortal.
##			Hidden Users will alwais displayed as Offline.
##			Only the Admin can see if a Hidden user is Online (via an extra Icon)!
##			A Mouseover info shows the Admin alwais if the User will be hidden.
## Note:		Another Online/Offline indicator mod must be already installed!
##			
## Installation Level:	Intermediate 
## Installation Time:	4 Minutes 
##
## Files To Edit:	3
##
##			portal.php
##			
##			templates/subSilver/portal_body.tpl
##			templates/subSilver/subSilver.cfg
##
################################################################################
## The following site also contain the latest version of this MOD: 
## 
## http://www.AmigaLink.de
## 
## Full support and addons for this MOD can be obtained at: 
##
## http://www.AmigaLink.de
##  
################################################################################
##
##  This hack is released under the GPL License. 
##  This hack can be freely used, but not distributed, without permission.
##  Intellectual Property Rights are retained by the hack author(s) 
##  listed above.
##
################################################################################
##
##  BEFORE ADDING THIS HACK TO YOUR FORUM, please be sure to backup ALL
##  affected files.
##
#################################################################################
#
#----------[ COPY FILES ]-------------------------------
#

copy online_small.gif to templates/subSilver/images/online_small.gif
copy offline_small.gif to templates/subSilver/images/offline_small.gif
copy hidden_online_small.gif to templates/subSilver/images/hidden_online_small.gif

#
#----------[ OPEN ]-------------------------------------
#

portal.php

#
#----------[ FIND ]-------------------------------------
#

// Start Top 5 Posters hack 
$sql = "SELECT post_id FROM " . POSTS_TABLE . " ORDER BY post_id DESC LIMIT 1"; 
$result = $db->sql_query($sql); 
$row = $db->sql_fetchrow($result); 
$total_post_perc = $row['post_id']; 
$perc_mult = 3; 
$perc_mult_set = 0; 
$rank = 0; 
$sql = "SELECT user_id, username, user_posts FROM " . USERS_TABLE ." WHERE user_id <> -1 ORDER BY user_posts DESC LIMIT 5"; 

#
#----------[ INLINE FIND ]------------------------------
#

$sql = "SELECT user_id, username, user_posts

#
#----------[ INLINE AFTER, ADD ]------------------------
#

, user_allow_viewonline, user_session_time

#
#----------[ FIND ]-------------------------------------
#

   $bar_perc = round($percentage * $perc_mult,0);

#
#----------[ AFTER, ADD ]-------------------------------
#

// <!-- BEGIN Another Online/Offline indicator -->
		if ( !$row['user_allow_viewonline'] && $userdata['user_level'] == ADMIN || $row['user_allow_viewonline'] )
		{
			$current_time = time();
			$expiry_time = $current_time - 300;

			if ( $row['user_session_time'] >= $expiry_time )
			{
				$user_onlinestatus = '<img src="' . $images['Online_small'] . '" alt="' . $lang['Online'] . '" title="' . $lang['Online'] . '" border="0" />';

				if ( !$row['user_allow_viewonline'] && $userdata['user_level'] == ADMIN )
				{
					$user_onlinestatus = '<img src="' . $images['Hidden_Admin_small'] . '" alt="' . $lang['Hidden'] . '" title="' . $lang['Hidden'] . '" border="0" />';
				}
			}
			else
			{
				$user_onlinestatus = '<img src="' . $images['Offline_small'] . '" alt="' . $lang['Offline'] . '" title="' . $lang['Offline'] . '" border="0" />';

				if ( !$row['user_allow_viewonline'] && $userdata['user_level'] == ADMIN )
				{
					$user_onlinestatus = '<img src="' . $images['Offline_small'] . '" alt="' . $lang['Hidden'] . '" title="' . $lang['Hidden'] . '" border="0" />';
				}
			}
		}
		else
		{
			$user_onlinestatus = '<img src="' . $images['Offline_small'] . '" alt="' . $lang['Offline'] . '" title="' . $lang['Offline'] . '" border="0" />';
		}
// <!-- END Another Online/Offline indicator -->

#
#----------[ FIND ]-------------------------------------
#

      'USERNAME' => $row['username'],

#
#----------[ AFTER, ADD ]-------------------------------
#

// <!-- BEGIN Another Online/Offline indicator -->
			'ONLINESTATUS' => $user_onlinestatus,
// <!-- END Another Online/Offline indicator -->

#
#----------[ OPEN ]-------------------------------------
#

templates/subSilver/portal_body.tpl

#
#----------[ FIND ]-------------------------------------
#

         <td class="rowpic" colspan="4" align="left" height="25"><span class="genmed"><b>Top 5 Posters</b></span></td> 

#
#----------[ INLINE FIND ]------------------------------
#

colspan="4"

#
#----------[ REPLACE WITH ]-----------------------------
#

colspan="5"

#
#----------[ FIND ]-------------------------------------
#

         <td class="row1" align="center"><span class="genmed">Member</span></td>

#
#----------[ INLINE FIND ]------------------------------
#

<td class="row1"

#
#----------[ INLINE AFTER, ADD ]------------------------
#

 colspan="2"

#
#----------[ FIND ]-------------------------------------
#

      <!-- BEGIN users -->

#
#----------[ AFTER, ADD ]-------------------------------
#

         <td class="row1" align="left">&nbsp;{users.ONLINESTATUS}</td> 

#
#----------[ OPEN ]-------------------------------------
#

templates/subSilver/subSilver.cfg

#
#----------[ FIND ]-------------------------------------
#

// Another Online_Offline indicator
$images['Online'] = "$current_template_images/online.gif"; 
$images['Offline'] = "$current_template_images/offline.gif";
$images['Hidden_Admin'] = "$current_template_images/hidden_online.gif";

#
#----------[ AFTER, ADD ]-------------------------------
#

$images['Online_small'] = "$current_template_images/online_small.gif"; 
$images['Offline_small'] = "$current_template_images/offline_small.gif";
$images['Hidden_Admin_small'] = "$current_template_images/hidden_online_small.gif";

#
#----------[ SAVE AND CLOSE ALL FILES ]-----------------
#
# EoM